package be.kuleuven.peno3.mobiletoledo.model;

public class Result {
	private int[] answers;
	
	public Result(int[] answers) {
		this.answers=answers;
	}

	public String calculateResult() {
		if(answers!=null){ 
			int total=0;
			for(int a:answers) {
				total+=a;
			}
			String result="Resultaat van de Poll:\n";
			for(int i=0;i<answers.length;i++) {
				result+=(i+1)+": "+(int)Math.round((float)answers[i]/(float)total*100.0)+"%\n";
			}

			return result;
		}
		else {
			return "";
		}
	}
}
